using System;
using Newtonsoft.Json.Bson;
namespace Daemon.Common.Time
{
    public static class TimeHelper
    {
        #region 获取时间差string GetTime(BsonString getTime)
        /// <summary>
        /// 获取时间差
        /// </summary>
        /// <param name="getTime">数据库时间</param>
        /// <returns>时间差</returns>
        public static string GetTime(DateTime getTime)
        {
            var time1 = getTime;
            var time = DateTime.Now - time1;

            if (time.TotalHours > 24)
            {
                return Math.Floor(time.TotalDays) + "天前";
            }
            if (time.TotalHours > 1)
            {
                return Math.Floor(time.TotalHours) + "小时前";
            }
            if (time.TotalMinutes > 1)
            {
                return Math.Floor(time.TotalMinutes) + "分钟前";
            }
            return Math.Floor(time.TotalSeconds) + "秒前";
        }
        #endregion
    }
}
